# import networkx as nx
import os
import glob
import imageio
import numpy as np
import cv2
# G =nx.Graph()

# image_folder = r'C:\Users\laozhang\Desktop\imgs'
# lines = [os.path.splitext(os.path.basename(xx))[0] for xx in glob.glob(os.path.join(image_folder, '*' + '.jpg'))]
# print(lines)

img = r'E:\TEST\aa.exr'
# img = r'E:\TEST\123\ttt.jpg'
# img = r'D:\MZ\MY\MY_01_01_001\render\All\All.0528.exr'
# img = r'C:\Users\laozhang\Desktop\imgs\dogs.jpg'
# # img = r'E:\TEST\123\t.tif'
#
# result = imageio.imread(img)
# # print(result.shape)
# print(result)
# # H, W = imageio.imread(img).shape[:2]
# # print(H)


# result2 = cv2.imread(img,2)
# result2 = cv2.imread(img,cv2.IMREAD_COLOR)
result2 = cv2.imread(img,cv2.IMREAD_UNCHANGED)
print(result2.shape)
# min_16bit = np.min(result2)
# max_16bit = np.max(result2)
# print(min_16bit)
# print(max_16bit)
#
# image_8bit = np.array(np.rint((255.0 * (result2 - min_16bit)) / float(max_16bit - min_16bit)), dtype=np.uint8)
#
# print(image_8bit)
# print(result2)
# print(type(result2))
# zz=None
# a=cv2.normalize(result2, result2, 0, 255, cv2.NORM_MINMAX)
# print(a)
# b=np.array([result2],dtype='uint8')
# print(b)
# result2=result2.astype(np.uint8)
# print(result2)
# result2= np.uint8(result2)
# last = cv2.cvtColor(a,cv2.COLOR_BGR2RGB)
# print(last.shape)
# print(last)


cv2.imwrite(r'E:\TEST\123\attt.jpg',result2)
cv2.imshow('a',result2)
cv2.waitKey(0)

# import torch
# 
# device = torch.device('cuda')
# print(device)